package com.cyk.mp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cyk.mp.mapper.UserMapper;
import com.cyk.mp.model.domain.QueryUserDTO;
import com.cyk.mp.model.domain.User;
import com.cyk.mp.model.domain.PageUserDTO;
import com.cyk.mp.service.IUserService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Override
    public User query(PageUserDTO dto) {

        return null;
    }

    @Override
    public List<User> query(QueryUserDTO dto) {
        return lambdaQuery()
                .in(!dto.getIds().isEmpty(), User::getId, dto.getIds())
                .eq(StringUtils.hasLength(dto.getName()), User::getName, dto.getName())
                .between(dto.getMinAge() != null && dto.getMaxAge() != null,
                        User::getAge, dto.getMinAge(), dto.getMaxAge())
                .list(); //生成一个 list    当然也可以选择生成 page 后面会讲
    }

}
